<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="com.ecomm.util.*" %>
<%@ include file="/include/pageexpires.jsp" %>
<%@ include file="/include/currentuserinfo.jsp" %>
<%@ include file="/include/filepath.jsp" %>
<%
String idname = Function.normalizeString(request.getParameter("idname"));
String disname = Function.normalizeString(request.getParameter("disname"));
String useridtem = Function.normalizeString(request.getParameter("userid"));

%>

<html>
  <head>
    <title>组织机构列表</title>
    <script language="javascript">
        function check() {
            var subGo = 0;
            var selname = "";
            var list = "";
            var idlisttree = tree.getAllChecked();
            var idlisttrees = idlisttree.split(",");
        for (var i = 0; i < idlisttrees.length; i++)
            {
                if (tree.getUserData(idlisttrees[i],'isuser') == 'true')
                {
                        subGo++;
                        list += idlisttrees[i];
                        selname += tree.getItemText(idlisttrees[i]);   
                }
            }

            if (subGo > 1)
            {
                alert("只能选择一个用户！");
                return false;
            }else if (subGo < 1)
            {
                alert("请选择一个用户！");
                return false;
            }
            window.opener.document.getElementById("<%=idname%>").value = list;
            window.opener.document.getElementById("<%=disname%>").value = selname;
            window.close();
        }

    </script>
    <link type="text/css" rel="stylesheet" href="<%=ctxpath%>/themes/newstyle/styles/office97/office97menu.css" id="menuStyleSheet">
    <link rel="STYLESHEET" type="text/css" href="<%=ctxpath%>/dhtmlxTree/css/dhtmlXTree.css">
    <script  src="<%=ctxpath%>/dhtmlxTree/javascript/dhtmlXCommon.js"></script>
    <script  src="<%=ctxpath%>/dhtmlxTree/javascript/dhtmlXTree.js"></script>	
    <script type="text/javascript" src="<%=ctxpath%>/themes/newstyle/javascript/menu3.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  
  
  <body topmargin="0" leftmargin="0" bgcolor="#ffffff" id="leftbody" bgproperties="fixed" scroll="auto">
    
    <form name="userform">
      <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="tree" align="center">
        <tr>
          <td valign="top" nowrap class="tree_td_top"><br><br>
            <%
            String id = request.getParameter("id");
            if(id== null || id.equals("")){
              id="";
            }
            %>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tree_middle">
              <tr>
                <td class="left"><img src="<%=ctxpath%>/themes/newstyle/styles/office97/tree/left_txt.gif"></td>
                <td valign="top" nowrap class="middle">
                  <div id="treeboxbox_tree"></div>
                  <script>
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%","<%=id%>");
			tree.setImagePath("<%=ctxpath%>/dhtmlxTree/imgs/");
			//enable checkboxes
		        tree.enableCheckBoxes(1);
		        //tree.enableRadiobuttons(<%=id%>,true);
		        tree.enableThreeStateCheckboxes(true);
                        // tree.setOnClickHandler(doOnClick);
                        tree.setXMLAutoLoading("<%=ctxpath%>/tree/DhtmlxTree/orgmodle.do?method=getOrgmodleUserXml&userid=<%=useridtem%>");
                        tree.loadXML("<%=ctxpath%>/tree/DhtmlxTree/orgmodle.do?method=getOrgmodleUserXml&id=<%=id%>&userid=<%=useridtem%>");
                  </script> 
                </td>
                <td class="right"></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td valign="bottom" nowrap class="tree_td_bottom" align="center">
            <input type="button" value="选择" Class="button" onclick="check(this)">
            <input type="button" value="返回" Class="button" onclick="window.close();"/>
          </td>
        </tr>
      </table>
      
    </form>
  </body>
</html>
